package Z03JiHeKuangJia.ArrayListStudy.T05BianLI;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class TestBianli {}

class Test{
    public static void main(String[] args) {
        List<Hero> heros = new ArrayList<>();
        for (int i = 0 ; i < 5 ; i++){
            heros.add(new Hero("hero name" + i));
        }
        System.out.println("---------for循环----------");
        for (int i = 0 ; i < heros.size() ;i++ ){
            Hero h = heros.get(i);
            System.out.println(h);
        }

        System.out.println("------使用fordeIterator-----");
        for (Iterator<Hero> iterator = heros.iterator();iterator.hasNext();){
            Hero hero = (Hero) iterator.next();
            System.out.println(hero);
            System.out.println(hero);
        }

        System.out.println("------增强型for循环------------");
        for(Hero h :heros){
            System.out.println(h);
        }
    }
}

class Hero{
    public String name;
    public float hp;
    public int damage;

    public Hero(){}
    public Hero(String name){
        this.name = name;
    }
    public String toString(){
        return name;
    }
}